import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';

import 'package:test_app/core/utils/common/common_util.dart';
import 'package:test_app/core/base/base/base_view.dart';
import 'package:test_app/core/design_system/extensions/widget/column_extension.dart';
import 'package:test_app/feature/home/order/order_controller.dart';

class OrderView extends BaseView<OrderController> {
  const OrderView({super.key});

  @override
  String? get navTitle => "订单详情";

  @override
  Widget body() {
    return Obx(() {
      final orderState = controller.orderState;

      final String? nickName = orderState.userInfo['nickName'];
      final int? userId = orderState.userInfo['userId'];
      return [
        Text('第一行'),
        if (CommonUtil.isNotNull(nickName)) Text('当前用户昵称: $nickName'),

        if (CommonUtil.isNotNull(userId)) Text('当前用户ID: $userId'),
        TDButton(
          text: '确认',
          type: TDButtonType.fill,
          onTap: () {
            debugPrint('OrderView -> confirm tapped');
            controller.back();
          },
        ),
        TDButton(
          text: '返回首页',
          type: TDButtonType.fill,
          onTap: () {
            debugPrint('OrderView -> back home tapped');
            controller.toHome();
          },
        ),
        TDButton(
          text: '读取本地数据',
          type: TDButtonType.fill,
          onTap: () {
            debugPrint('OrderView -> read local data tapped');
            controller.readUserInfo();
          },
        ),
      ].toColumn(spacing: 10.0);
    });
  }
}
